package com.youlai.system.controller;

import com.youlai.system.common.result.Result;
import com.youlai.system.model.entity.AirOrder;
import com.youlai.system.service.AirOrderService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @version 1.0
 * @Author Ricardo
 * @Date 2024/10/24 15:25
 * @注释
 */
@Tag(name = "12.订单信息接口")
@RestController
@RequestMapping("/api/v1/order")
@RequiredArgsConstructor
public class AirOrderController {
    @Autowired
    private AirOrderService airOrderService;

    @PostMapping("/add")
    public Result addPlaneInformation(AirOrder airOrder){
        if (airOrderService.saveOrUpdate(airOrder)){
            return Result.success();
        }else {
            return Result.failed();
        }
    }
    @PutMapping("/delete")
    public Result deletePlaneInformation(long plane_id){
        if (airOrderService.removeById(plane_id)){
            return Result.success();
        }else {
            return Result.failed();
        }
    }

    @GetMapping("/select")
    public Result<List<AirOrder>> searchPlaneInformation(){
        if (airOrderService.list()!=null){
            return Result.success(airOrderService.list());
        }else {
            return Result.failed();
        }
    }
}
